import Vue from "vue";
import VueRouter from 'vue-router';
import Login from '../pages/Login.vue';
import Score from '../pages/Score.vue';
Vue.use(VueRouter);

const routes = [
    { 
        path: '/', 
        name: 'Login', 
        component: Login, 
    },
    {
        path: '/home',
        name: 'Home',
        redirect: '/home/score',
        component: () => import('../layout/BasicLayout.vue'),
        children: [
            {
                path: '/home/score',
                name: 'Score',
                meta: { requiresAuth: true, permission: ['user', 'admin', 'super'] },
                component: Score
            },
            {
                path: '/home/record',
                name: 'Record',
                meta: { requiresAuth: true, permission: ['user', 'admin', 'super'] },
                component: () => import('@/pages/Record.vue')
            },
            {
                path: '/home/person',
                name: 'Person',
                meta: { requiresAuth: true, permission: ['user', 'admin', 'super'] },
                component: () => import('@/pages/Person.vue')
            },
            {
                path: '/home/report',
                name: 'Report',
                meta: { requiresAuth: true, permission: ['admin', 'super'] },
                component: () => import('@/pages/Report.vue')
            },
            {
                path: '/home/deptadmin',
                name: 'DeptAdmin',
                meta: { requiresAuth: true, permission: ['super'] },
                component: () => import('@/pages/DeptAdmin.vue')
            },
            {
                path: '/home/useradmin',
                name: 'UserAdmin',
                meta: { requiresAuth: true, permission: ['super'] },
                component: () => import('@/pages/UserAdmin.vue')
            },
            {
                path: '/home/positionadmin',
                name: 'PositionAdmin',
                meta: { requiresAuth: true, permission: ['super'] },
                component: () => import('@/pages/PositionAdmin.vue')
            },
            {
                path: '/home/scorerules',
                name: 'ScoreRules',
                meta: { requiresAuth: true, permission: ['super'] },
                component: () => import('@/pages/ScoreRules.vue')
            },
            {
                path: '/home/coefficient',
                name: 'Coefficient',
                meta: { requiresAuth: true, permission: ['super'] },
                component: () => import('@/pages/Coefficient.vue')
            }
        ]
        
    },
    {
        path: '*',
        component: () => import('../pages/404.vue')
    }
]

const router = new VueRouter({
    mode: 'history',
    routes
})

export default router;